﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="shipu_clone03.aspx.cs" Inherits="Catering.Catering_Page.Caipin.Caipin_jcsz.shipu_clone03" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../../Scripts/date.js" type="text/javascript"></script>
    <style type="text/css">
        .outprev{ background-color:#ccccff;}
        .outnext{ background-color:#9999ff;}
        .outtoday{background-color: #000099;}
        
        .tableWeek{background-color: #cbedd2;}
        .tableWeek tr td{height:20px; line-height:20px;}
        .tableWeek tr td input{ vertical-align:middle;}
    </style>
</head>
<script language="javascript" type="text/javascript">
        var datelist = "";
        var showdatetime = new Date();
        var in_datetime = new Date();
        var selected_index = 0;
        var selected_count = '<%=m_CheckDayCount %>';
        var tempClour = new Array(Cloumnum);

        var Cloumnum = 0;
        function prevM()  //往前翻月份
        {
            in_datetime = new Date(showdatetime.setMonth(showdatetime.getMonth() - 1));
            $("#pseldate").html(writeCalendar(in_datetime));
            SetTableStyle();
        }

        function nextM()  //往后翻月份
        {
            in_datetime = new Date(showdatetime.setMonth(showdatetime.getMonth() + 1));
            $("#pseldate").html(writeCalendar(in_datetime));
            SetTableStyle();
        }

        //选择日期
        function SetClClour(i) {
            selected_index = 0;
            var IsSeleted = $("#tr_" + i + " input[name='Checkbox']").attr("checked");
            if (IsSeleted) {
                $("#tr_" + i + " td").each(function () {
                    if (selected_index < selected_count) {
                        tempClour[selected_index] = $(this).css("background-color");
                        $(this).css("background-color", "ff9311");
                        if (selected_index == 1) {
                            $(this).attr("selectedstart", "true");
                        }
                        if (selected_index == (selected_count - 1)) {
                            $(this).attr("selectedend", "true");
                        }
                        selected_index += 1;
                    }
                });
            }
            else {
                $("#tr_" + i + " td").each(function () {
                    if (selected_index < selected_count) {
                        $(this).css("background-color", tempClour[selected_index]);
                        selected_index = selected_index + 1;
                    }
                    $(this).removeAttr("selectedstart");
                    $(this).removeAttr("selectedend");
                });
            }
        }

        function Day_Make(day) {
            selected_count = day;
            $("#hf_selectdate").val(day);
            $("#hf_selectdate").val(day);
        }

        //startdate>=enddate   true
        function dateCompare(startdate, enddate) {
            var arr = startdate.split("-");
            var starttime = new Date(arr[0], arr[1], arr[2]);
            var starttimes = starttime.getTime();

            var arrs = enddate.split("-");
            var lktime = new Date(arrs[0], arrs[1], arrs[2]);
            var lktimes = lktime.getTime();

            if (starttimes >= lktimes) {
                return true;
            }
            else
                return false;
        } 


        //权限控制
        function SetTableStyle() {
            if ($("#HidIsQun").val() != "true")
                return;

            var starttime = $("#pseldate td[IsDate='true']:first").attr("date");
            var endtime = $("#pseldate td[IsDate='true']:last").attr("date");
            var ClassID = $("#HidClassID").val();
            var recipesid = "<%=m_RecipesID %>";

            $.ajax({
                type: "Post",
                url: "shipu_clone03.aspx/GetDatatime",
                data: "{'starttime':'" + starttime + "','endtime':'" + endtime + "','ClassID':'" + ClassID + "','StrRecipesID':'" + recipesid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var DateArray = data.d.split(',');
                    $("#pseldate td[IsDate='true']").each(function () {
                        var date = $(this).attr("date");
                        for (var i = 0; i < DateArray.length; i++) {
                            var Stime = DateArray[i].split('|')[0];
                            var Etime = DateArray[i].split('|')[1];
                            if (dateCompare(date, Stime) && dateCompare(Etime, date)) {
                                $(this).css("background-color", "#999");
                                $(this).parent().find("input").attr("disabled",true);
                            }
                        }
                    });
                }
            });
        }

        $(document).ready(function () {
            $("#pseldate").html(writeCalendar(new Date()));
            SetTableStyle();

        });

        function Next_But_Click_Js() {
            var selectedDate="";
            $("#pseldate").find("input[checked='true']").each(function () {
                var startTime = $(this).parents("tr").find("td[selectedstart]").attr("date");
                var endTime = $(this).parents("tr").find("td[selectedend]").attr("date");
                selectedDate += startTime + "|" + endTime + ",";
            });
            $("#hf_datelist").val(selectedDate);
            $("#Next_But").click();
        }

        //触发下一步操作
        function btn_next_click() {
            $("#btn_next").trigger("click");
        }
</script>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hf_selectdate" runat="server" Value="<%=m_CheckDayCount %>" />
    <asp:HiddenField ID="hf_datelist" runat="server" />
    <asp:HiddenField ID="HidIsQun" runat="server" />
    <asp:HiddenField ID="HidClassID" runat="server" />
    <div class="nav_2">
        <div class="nav_2_1">
            <img src="../../../Images/nav2_bg1.gif" /></div>
        <ul>
            <li><a href="javascript:void(0);"><span id="span_peic_1" class="feise_border">1.配餐人群设置</span></a></li>
            <li><a href="javascript:void(0);"><span id="span_peic_2" class="lvse_border">2.选择配餐日期</span></a></li>
            <li style="background: none"><a href="javascript:void(0);"> <span id="span_peic_3" class="feise_border">3.生成食谱</span></a></li>
        </ul>
        <div class="nav_2_3">
            <img src="../../../Images/nav2_bg2.gif" /></div>
    </div>
    <div style="width:800px; text-align:center;margin:0px auto;">
    <div>
        <input id="prebutton" type="button" class="input_btn_a" style="margin:10px auto;" onclick="prevM()" value="上一月" /></div>
    <div style=" margin:0px auto; padding:0px auto; text-align:center;">
        <p id="pseldate">
        </p>
    </div>
    <div>
        <input id="aabutton" type="button" class="input_btn_a" style="margin:10px auto;" onclick="nextM()" value="下一月" />
    </div>
    <div style="line-height:20px;">
        <input id="Radio2" type="radio" disabled="disabled" checked="checked"  name="radio_tian" /><%=(m_CheckDayCount-1) %>天制
    </div>
     <div class="table_box02_03"  >
           <asp:Button ID="Next_But" runat="server" OnClick="Next_But_Click" style="display:none"/>
       
                <a onclick="Next_But_Click_Js()" id="btn_next"   href="#">下一步</a>
            </div>
    </div>
    <div class="footer">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司&nbsp;&nbsp;版权所有@CopyRight 2012</strong><span>技术支持：北京天择嘉业科技有限公司</span>
    </div>
    </form>
</body>
</html>
